import typing as t


def get_bagging(max_samples: float,
                n_estimators: int = 1000,
                min_weight_fraction_leaf: float = 0.,
                n_jobs: t.Optional[int] = -1):
    """Bagging分类器"""
    from sklearn.ensemble import BaggingClassifier
    from sklearn.tree import DecisionTreeClassifier

    clf = DecisionTreeClassifier(criterion='entropy',
                                 max_features=1,
                                 class_weight='balanced',
                                 min_weight_fraction_leaf=min_weight_fraction_leaf)
    clf = BaggingClassifier(base_estimator=clf,
                            n_estimators=n_estimators,
                            max_features=1.,
                            max_samples=max_samples,
                            n_jobs=n_jobs)
    return clf
